﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cecbData;

namespace cecbClasses.Data_Adapters.Setting
{
    public class Func_Settings
    {
        public Func_Settings() {

            cecbContext = new DSSEntities();

        }

        DSSEntities cecbContext;

        public String getLastMailID() {

            var idKey = (from c in cecbContext.Settings
                          where c.settingID == 3
                         select c).First();


            return  idKey.Value.ToString();
        }


        public String getLastMail()
        {

            var idKey = (from c in cecbContext.Settings
                         where c.settingID == 1
                         select c).First();


            return idKey.Value.ToString();
        }


        public String getLastMailPass()
        {

            var idKey = (from c in cecbContext.Settings
                         where c.settingID == 2
                         select c).First();


            return idKey.Value.ToString();
        }


        public bool updateSetting(int setID , String newVal )
        {
            bool isupdated = false;

            try
            {

                Settings settobj = cecbContext.Settings.First(i => i.settingID == setID);

                //    ProjectImpacts projectimpactObject = dataContext.ProjectImpacts.First(i => i.ImpactsReference == impt_ref);

                settobj.Value = newVal;
                //    activityObject.actv_phase = activity_phase;


                cecbContext.SaveChanges();
                isupdated = true;


            }
            catch (Exception)
            {

            }

            return isupdated;

        }
    }

}
